package com.example.springboot.service;


import com.example.springboot.mapper.WorkshopDao;
import com.example.springboot.pojo.Equipment;
import com.example.springboot.pojo.Workshop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service("workshopService")
public class WorkshopServiceImpl{
    @Autowired
    WorkshopDao workshopDao;


    public boolean addWorkshop(Workshop workshop) {
        if(workshopDao.queryById(workshop.getId())!=null)
            return false;
        workshopDao.addWorkshop(workshop);
        return true;
    }

    public Workshop queryById(int id) {
        Workshop workshop = workshopDao.queryById(id);
        return workshop;
    }


    public boolean deleteById(int id) {
        if(workshopDao.queryById(id)==null)
            return false;
        workshopDao.deleteById(id);
        return true;
    }


    public List<Workshop> getWorkshopList() {
        List<Workshop> workshopList = workshopDao.getWorkshopList();
        return workshopList;
    }

    public boolean updateById(Workshop workshop) {
        if(workshopDao.queryById(workshop.getId())==null)
            return false;
        workshopDao.updateById(workshop);
        return true;
    }


    public boolean MultideleteById(List<Integer> list) {
        for(int i:list){
            workshopDao.deleteById(i);
        }
        return true;
    }

    public List<Workshop> getWorkshopListByCondition(Map<String, String> map) {
        return workshopDao.getWorkshopListByCondition(map);
    }

    public List<Equipment> getEquipmentListById(int id) {
        return workshopDao.getEquipmentListById(id);
    }
}
